<template>
  <div class="main">
    <div class="showBox">
      <div class="title">
        <span>开始游戏</span>
        <img src="../../../static/image/showClose.png" alt="" @click="$router.push({path:'/seed/2'})">
      </div>
      <div class="number">
        <span>{{arr[id-1]}}种子:</span>
        <input type="text" :placeholder="'请输入'+arr[id-1]+'种子数量'" v-model="seed" @focus='message="温馨提示： 为了更好的游戏体验，亲您的充值还请小于4000枚哦"'>
      </div>
      <div class="tips">
        <p>{{message}}</p>
      </div>
      <div class="imgs">
        <img src="../../../static/image/X-btn.png" alt="" @click="$router.push({path:'/seed/2'})">
        <img src="../../../static/image/Accept-btn.png" alt="" @click="changePage">
      </div>
    </div>
    <!-- <div>
      <img src="../../../static/image/loadingx.gif" alt="">
    </div> -->
  </div>
</template>
<script>
export default {
  name: "digPopup",
  data() {
    return {
      id: this.$route.params.id.split("|")[0],
      arr: ["金", "银", "铜"],
      seed: "",
      flag: true,
      message: "温馨提示： 为了更好的游戏体验，亲您的充值还请小于4000枚哦"
    };
  },
  created() {
    this.$parent.flag1 = false;
    this.$parent.flag2 = false;
  },
  methods: {
    back() {
      history.back();
    },
    changePage() {
      if (!this.flag) {
        return;
      }

      if (this.id == "1" && this.seed > u.getStore("userInfo").seeds_amount) {
        this.message = "金种子数量超过您的余额";
        return;
      } else if (
        this.id == "2" &&
        this.seed > u.getStore("userInfo").silver_seeds_amount
      ) {
        this.message = "银种子数量超过您的余额";
        return;
      } else if (
        this.id == "3" &&
        this.seed > u.getStore("userInfo").copper_seeds_amount
      ) {
        this.message = "铜种子数量超过您的余额";
      }
      if (this.seed > 0 && this.seed <= 4000) {
        this.flag = false;
        u.palygame(
          {
            type: parseInt(this.id),
            activityId: this.$route.params.id.split("|")[1],
            seedNum: parseInt(this.seed),
            username: u.getStore("user").userid
          },
          data => {
            this.flag = true;
            if (data && data[0].code == "200") {
              this.$router.push({
                path: "/digSuccess/" + this.seed + "|" + this.arr[this.id - 1]
              });
            } else if (data && data[0].data && data[0].data.count < this.seed) {
              this.message = "剩余票劵数为" + data[0].data.count;
            } else {
              this.message = data[0].message;
            }
          }
        );
      } else {
        this.message = "亲您的充值还请在0~4000枚之间哦";
        this.seed = 0;
      }
    },
    //返回上一页
    back() {
      history.back();
    }
  }
};
</script>
<style scoped>
@import url("../../css/base.css");
.main {
  width: 100vw;
  height: 100vh;
  background: url("../../../static/image/ginsengbg2.png") no-repeat center;
  background-size: 100% 100%;
  padding-top: 15%;
}
.showBox {
  width: 443px;
  height: 282px;
  background: url("../../../static/image/showWin.png") no-repeat center;
  background-size: 100% 100%;
  margin: 0 auto;
  padding: 40px 25px;
}
.showBox .title,
.showBox .number {
  width: 100%;
  display: flex;
  flex-direction: row;
  justify-content: space-between;
}
.showBox .title span {
  font-size: 22px;
  color: #ffffff;
  font-weight: bold;
  text-shadow: 0 2px #8d4707, 2px 0 #8d4707, -2px 0 #8d4707, 0 -1px #8d4707;
}
.showBox .title img {
  width: 16px;
  height: 16px;
  cursor: pointer;
}
.showBox .number {
  margin-top: 50px;
  margin-bottom: 5px;
}
.showBox .number span {
  height: 18px;
  color: #ffffff;
  text-shadow: 0 2px #3a230a, 2px 0 #3a230a, -2px 0 #3a230a, 0 -1px #3a230a;
  font-weight: bold;
}
.showBox .number input {
  background: url("../../../static/image/bpxnumber.png") no-repeat center;
  background-size: 100% 100%;
  width: 323px;
  height: 43px;
  padding-left: 6%;
  margin-top: -3%;
}
.showBox .number input::-webkit-input-placeholder {
  color: #f1e0c8;
  font-weight: bold;
  text-shadow: 0 2px #bd8848, 2px 0 #bd8848, -2px 0 #bd8848, 0 -1px #bd8848;
  /* text-shadow: -2px 2px 0px #9f6946, -2px -1px 3px #9f6946; */
  /* text-shadow: px 2px 2px #bd8848; */
}
.showBox .tips {
  width: 100%;
  display: flex;
  flex-direction: row;
  /* justify-content: flex-end; */
  padding-left: 20%;
  margin-bottom: 45px;
  height: 40px;
}
.showBox .tips p {
  font-size: 14px;
  color: #ffffff;
  text-shadow: 0 1px #a76d30, 1px 0 #a76d30, -1px 0 #a76d30, 0 -1px #a76d30;
}
.showBox .imgs {
  width: 100%;
  display: flex;
  flex-direction: row;
  justify-content: space-around;
}
.showBox .imgs img {
  cursor: pointer;
}
</style>

